package cn.wolfcode.car.business.service.impl;

import cn.wolfcode.car.business.domain.Employee;
import cn.wolfcode.car.business.mapper.EmployeeMapper;
import cn.wolfcode.car.business.query.EmployeeQuery;
import cn.wolfcode.car.business.service.IEmployeeService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class EmployeeImpl extends ServiceImpl<EmployeeMapper,Employee> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;



    @Override
    public TablePageInfo<Employee> query(EmployeeQuery qo) {
        /*IPage<Employee> page = new Page<>(qo.getPageNum(), qo.getPageSize());
        QueryWrapper<Employee> wrapper = Wrappers.<Employee>query();
        //关键字查询
        wrapper.like(StringUtils.hasText(qo.getUsernameOrEmail()),"name",qo.getUsernameOrEmail()).or().like("email",qo.getUsernameOrEmail());
        wrapper.eq(qo.getSuperName()!=null,"admin",qo.getSuperName());
        wrapper.eq((qo.getStatus())!=null,"status",qo.getStatus());
        wrapper.ge(qo.getBeginTime()!=null,"hiredate",qo.getBeginTime());
        wrapper.le(qo.getEndTime()!=null,"hiredate",qo.getEndTime());
        wrapper.eq(qo.getDeptId()!=null,"dept_id",qo.getDeptId());
        IPage<Employee> employeeIPage = employeeMapper.selectPage(page, wrapper);
        return new TablePageInfo<Employee>(super.page(employeeIPage,wrapper).getRecords());*/
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        return new TablePageInfo<Employee>(employeeMapper.selectForList(qo));
    }
}
